<?php
$this->breadcrumbs = array(
    'Users' => array('admin'),
    'Manage',
);

$this->menu = array(
    array('label' => 'List User', 'url' => array('index')),
    array('label' => 'Create User', 'url' => array('create')),
);
$this->headTitle = "Manage Users";

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('user-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<?php //echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
    <?php
//$this->renderPartial('_search',array(
//	'model'=>$model,
//)); 
    ?>
</div>

<div class="widget">
    <div class="head">
        <h5 class="iFrames">User List</h5>
    </div>
    <div class="body">
        <?php
        $this->widget('zii.widgets.grid.CGridView', array(
            'id' => 'user-grid',
            'dataProvider' => $model->searchIsTrashed($isTrashed),
            'filter' => $model,
            'cssFile' => Yii::app()->baseUrl . Constant::CGRIDVIEW_CSS_URL,
            'template' => Constant::GRIDVIEW_TEMPLATE,
            'pager' => array(
                'header' => Constant::PAGER_HEADER,
                'cssFile' => Yii::app()->baseUrl . Constant::PAGER_CSS_URL,
                'prevPageLabel' => Constant::PAGER_PREV_PAGE_LABEL,
                'nextPageLabel' => Constant::PAGER_NEXT_PAGE_LABEL,
            ),
            'columns' => array(
                array(
                    'name' => 'userId',
                    'value' => 'CHtml::encode($data->userId)',
                    'htmlOptions' => array('width' => '10'),
                ),
                array(
                    'name' => 'avatarUrl',
                    'type' => 'html',
                    'value' => 'CHtml::image( Yii::app()->request->baseUrl . "/../uploads/users/" . $data->avatarUrl,"",array("width"=>"150", "height"=>"150"))',
                    'htmlOptions' => array('width'=>'20'),
                ),
                array(
                    'name' => 'name',
                    'value' => 'CHtml::encode($data->name)',
                    'htmlOptions' => array('width' => '100'),
                ),
                array(
                    'name' => 'email',
                    'value' => 'CHtml::encode($data->email)',
                    'htmlOptions' => array('width' => '150'),
                ),
                array(
                    'name' => 'sex',
                    'value' => 'CHtml::encode($data->getSexText())',
                    'htmlOptions' => array('width' => '40'),
                ),
                array(
                    'header' => 'Commands',
                    'class' => 'CButtonColumn',
                    'template' => $template,
                    'htmlOptions' => array('width'=> Constant::CBUTTONCOLUMN_WIDTH),
                    'buttons' => array(
                        'update' => array(
                            'update' => 'update',
                            'imageUrl' => Yii::app()->request->baseUrl . Constant::CRUD_IMAGE_URL_EDIT,
                        ),
                        'view' => array(
                            'view' => 'view',
                            'imageUrl' => Yii::app()->request->baseUrl . Constant::CRUD_IMAGE_URL_VIEW,
                        ),
                        'trash' => array(
                            'view' => 'trash',
                            'label' => 'Trash',
                            'imageUrl' => Yii::app()->request->baseUrl . Constant::CRUD_IMAGE_URL_TRASH,
                            'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->id  . '/trash", array("id" => $data->primaryKey))',
                        ),
                        'untrash' => array(
                            'view' => 'untrash',
                            'label' => 'Untrash',
                            'imageUrl' => Yii::app()->request->baseUrl . Constant::CRUD_IMAGE_URL_UNTRASH,
                            'url' => 'Yii::app()->createUrl("' . Yii::app()->controller->id  . '/untrash", array("id" => $data->primaryKey))',
                        ),
                        'delete' => array(
                            'delete' => 'delete',
                            'imageUrl' => Yii::app()->request->baseUrl . Constant::CRUD_IMAGE_URL_DELETE,
                        ),
                    ),
                ),
            ),
        ));
        ?>
    </div>
</div>

<div class="widget">
    <div class="head closed inactive">
        <h5>Search</h5>
    </div>
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>
</div>